﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Douban.Api.Infrastructure;

namespace Douban.Api.User
{
    [Entry]
    public class Author : EntryItem
    {
        private string _iconUri;
        private const string DefaultIconUri = "http://t.douban.com/icon/user.jpg";

        public Author() { }

        public Author(UserDetail detail)
        {
            Id = detail.Id;
            Name = detail.Name;
            IconUri = detail.IconUri;
            DoubanPage = detail.DoubanPage;
        }

        [Element("name")]
        public string Name { get; set; }

        [Id]
        public string Id { get; set; }

        [Link("icon")]
        public string IconUri 
        {
            get
            {
                if (string.IsNullOrEmpty(_iconUri)) return DefaultIconUri;
                return _iconUri;
            }
            set { _iconUri = value; }
        }

        [Link("alternate")]
        public string DoubanPage { get; set; }
    }
}
